package com.endava.nio_io;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.channels.FileChannel;

public class Nio_CopyingAFile {
	public static void main(String[] args) throws IOException {
		
		File f=new File("file.in");
		if(f.exists()==false){
			f.createNewFile();
		}else{
			System.out.println(f);
		}
		
		
		FileInputStream fileInputStream = new FileInputStream("file.in");
		FileChannel inChannel=fileInputStream.getChannel();
		FileOutputStream fileOutputStream = new FileOutputStream("file.out");
		FileChannel outchChannel=fileOutputStream.getChannel();
		
		
		outchChannel.transferFrom(inChannel, 0, inChannel.size());
		fileInputStream.close();
		fileOutputStream.close();
	}
}
